import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { createStyleImportPlugin } from 'vite-plugin-style-import';
import path from 'path'


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()/* , createStyleImportPlugin({
    libs:[
      {
        libraryName:'zarm',
        esModule:true,
        resolveStyle: (name) => {
          return 'zarm/es/${name}/style/css';
        }
      }
    ]
  })*/],
  css: {
    module: {
      localConvention: "dashesOnly",
    },
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      }
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://api.chennick.wang/api/',
        changeOrigin: true,
        rewrite : path => path.replace(/^\/api/, '') // 将 /api 重写为空
      }
    }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'), // src 路径
      'utils': path.resolve(__dirname, 'src/utils') // src 路径
    }
  }
})